<?php
define('CONF_PATH',dirname(realpath(__FILE__)) . "/");
define('BASE_PATH',dirname(CONF_PATH));
define('APP_PATH',BASE_PATH . "/app/");

include(CONF_PATH.'private_info.php');
// Get environment variable set into virtual host
$environment = getenv('APPLICATION_ENV');
if ($environment === false && defined('APPLICATION_ENV')) {
	$environment = APPLICATION_ENV;
}

// Retro-compatibility : old project whitout environment variable defined into virtual host
if (empty($environment) || $environment === false) {
	if (!isset($_SERVER) || !isset($_SERVER["SERVER_NAME"])) {
		$hostname = exec("hostname");
	}
	else {
		//$hostname = gethostbyaddr(gethostbyname($_SERVER["SERVER_NAME"]));
		$hostname = $_SERVER["SERVER_NAME"];
	}

	switch ($hostname) {
		case 'stage.unkri.ch':
		case 'stage.kristine.unkri.ch':
			$environment = 'staging';
			break;
		case 'unkri.ch':
		case 'kristine.unkri.ch':
			$environment = 'prod';
			break;
		case 'localhost':
		case '127.0.0.1':
		case '192.168.0.11':
		case 'unkrich.dev':
		default:
			$environment = 'dev';
			break;
	}
}

switch ($environment) {
	case "dev":
		$GLOBALS['TL_CONFIG']['environnement'] = 'dev';
		$GLOBALS['TL_CONFIG']['activateSession'] = false;
		$GLOBALS['TL_CONFIG']['dbDatabase'] = 'unkrichkristine';
		$GLOBALS['TL_CONFIG']['dbHost'] = 'localhost';
		$GLOBALS['TL_CONFIG']['dbUser'] = 'root';
		$GLOBALS['TL_CONFIG']['dbPass'] = 'root';
		$GLOBALS['TL_CONFIG']['minScript'] = '';
		$GLOBALS['TL_CONFIG']['statics'] = 'http://static.unkrich.dev/';
		$GLOBALS['TL_CONFIG']['jsStatics'] = 'http://static.frank.dev/';
		break;
	case "staging":
		$GLOBALS['TL_CONFIG']['environnement'] = 'staging';
		$GLOBALS['TL_CONFIG']['activateSession'] = true;
		$GLOBALS['TL_CONFIG']['dbDatabase'] = 'unkrichkristine';
		$GLOBALS['TL_CONFIG']['dbHost'] = $private_ovh_db_server;
		$GLOBALS['TL_CONFIG']['dbUser'] = $private_ovh_db_user;
		$GLOBALS['TL_CONFIG']['dbPass'] = $private_ovh_db_pwd;
		$GLOBALS['TL_CONFIG']['minScript'] = '';
		$GLOBALS['TL_CONFIG']['statics'] = 'http://static.unkri.ch/';
		$GLOBALS['TL_CONFIG']['jsStatics'] = 'http://static.frank.gairal.com/';
		break;
	case "prod":
	default:
		$GLOBALS['TL_CONFIG']['environnement'] = 'prod';
		$GLOBALS['TL_CONFIG']['activateSession'] = true;
		$GLOBALS['TL_CONFIG']['dbDatabase'] = 'unkrichkristine';
		$GLOBALS['TL_CONFIG']['dbHost'] = $private_ovh_db_server;
		$GLOBALS['TL_CONFIG']['dbUser'] = $private_ovh_db_user;
		$GLOBALS['TL_CONFIG']['dbPass'] = $private_ovh_db_pwd;
		$GLOBALS['TL_CONFIG']['minScript'] = '.min';
		$GLOBALS['TL_CONFIG']['statics'] = 'http://static.unkri.ch/';
		$GLOBALS['TL_CONFIG']['jsStatics'] = 'http://static.frank.gairal.com/';
		break;
}
define ("VERSION_NUMBER", 'v1.0.0 - February 2013');

define('DB_SERVER', $GLOBALS['TL_CONFIG']['dbHost']);
define('DB_USER', $GLOBALS['TL_CONFIG']['dbUser']);
define('DB_PWD', $GLOBALS['TL_CONFIG']['dbPass']);
define('DB_NAME', $GLOBALS['TL_CONFIG']['dbDatabase']);
define('BKF_ENV', $GLOBALS['TL_CONFIG']['environnement']);
define('ACTIVATE_SESSION', $GLOBALS['TL_CONFIG']['activateSession']);

define('STATIC_PATH', $GLOBALS['TL_CONFIG']['statics']);
define('JS_STATIC_PATH', $GLOBALS['TL_CONFIG']['jsStatics']);
define('ROOT_PATH', '/');

define ('MDL_ROOT', APP_PATH.'mdl/');
define ('CTRL_ROOT', APP_PATH.'ctrl/');
define ('VIEW_ROOT', APP_PATH.'view/');
define ('ERROR_ROOT', APP_PATH.'errors/');

define ("SKILL_TABLE", 'kristine.skill');
define ("EDUCATION_TABLE", 'kristine.education');
define ("EXPERIENCE_TABLE", 'kristine.experience');
define ("SKILL_GROUP_TABLE", 'kristine.skill_group');
define ("SKILL_FAMILY_TABLE", 'kristine.skill_family');
define ("SKILL_EDUCATION_TABLE", 'kristine.education_skill');
define ("SKILL_EXPERIENCE_TABLE", 'kristine.experience_skill');
define ("INTEREST_TABLE", 'kristine.interest');
define ("INTEREST_CATEGORY_TABLE", 'kristine.interest_category');
define ("TRAVEL_TABLE", 'kristine.travel');

//SESSION
define("NAVIGATION", 'navigation');
define("ALL_SKILLS", 'allSkills');
define("EXPERIENCE", 'experience');
define("EDUCATION", 'education');
define("INTERESTS", 'interests');
define("TRAVEL", 'travel');
define("ROADMAP", 'roadmap');
define("MEP", 'mep');

//URL
define ('FIELDS_PARAM', 'fields');
define ('ID_PARAM', 'id');
define ('MIN_SCRIPT', $GLOBALS['TL_CONFIG']['minScript']);
define ('METHOD_PARAM', 'method');
define ('VIEW_PARAM', 'view');

//MENU
$navArray = array (
	"motivation" => array ("viewTitle" => "Motivation"),
	"experience" => array ("viewTitle" => "Experience"),
	"education" => array ("viewTitle" => "Education"),
	"skills" => array ("viewTitle" => "Skills"),
	"interests" => array ("viewTitle" => "Interests"));

    
$cst = 'cst';
function cst($constant){
    return $constant;
}
include_once(MDL_ROOT.'frank.php');